package com.sky.controller.user;

import com.sky.result.Result;
import com.sky.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
public class UserSetmealController {

    @Autowired
    private SetmealService setmealService;


    // 根据分类id查询菜品
    @GetMapping("/list")
    @Cacheable(value = "setmealCache",key = "#categoryId")
    public Result selectByType(Integer categoryId){
        log.info("根据分类id查询菜品,接收到的参数是{}",categoryId);

        return Result.success(setmealService.userSelectByCategoryId(categoryId));
    }

    // 根据套餐id查询包含的菜品
    @GetMapping("/dish/{setmealId}")
    public Result selectDishBySetmealId(@PathVariable Integer setmealId ){
        log.info("根据套餐id查询包含的菜品,接收到的参数是{}",setmealId);
        return Result.success(setmealService.selectBySetmealId(setmealId));
    }
}
